﻿#pragma once

#include"Common.hpp"

class CentralCache
{
public:
	static CentralCache* GetInstance()
	{
		return &_sInit;
	}
	// 获取⼀个⾮空的span
	Span * GetOneSpan(SpanList& list, size_t size);
	// 从中⼼缓存获取⼀定数量的对象给thread cache
	size_t FetchRangeObj(void*& start, void*& end, size_t batchNum, size_t size);
	// 将⼀定数量的对象释放到span跨度
	void ReleaseListToSpans(void* start, size_t size);
private:
	SpanList _spanLists[NFREELIST];
private:
	CentralCache()
	{}
	CentralCache(const CentralCache&) = delete;

	CentralCache& operator=(const CentralCache&) = delete;
	static CentralCache _sInit;
};
